{template head}
<script type="text/javascript">
var ajaxparam = {
		'url' : '{SITE_URL}/ajax/index.php'
};

function deladmin(id,status,str){
	if(id)
	{
		
		layer.confirm('你确定执行'+str+'操作吗？', {
		  time: 0 //不自动关闭
		  ,btn: ['很确定', '点错了']
		  ,yes: function(index){
		    layer.close(index);
		    
		    
		    var url = ajaxparam.url + '?m=roleStatus';
			var data = {
					'id' : id,
					'status':status,
					'str':str,
			};
			var callback = function(data){
				if(data.sign == 1)
				{
					layer.alert(data.msg,function(){
						window.location = window.location;
					});
				}
				else
				{
					if(data.msg)
					{
						layer.msg(data.msg);
					}
					else
					{
						layer.msg('操作失败');
					}
				}
			};
			makeAjax('post',url,data,callback);
		    
		    
		    
		    
		    
		    
		    
		    
		  }
		});
		
		
		
		
	}else{
		alert('参数错误');
	}
}

function add()
{
	layer.open({
		  type: 1
		  ,title:'添加渠道'
		  ,offset: 'auto' //具体配置参考：offset参数项
		  ,content: '<div style="padding: 20px 20px;">渠道名称：<input type="text" id="name" name="name" class="mr15 w200 text"></div>'
		  ,btn: '保存'
		  ,btnAlign: 'c' //按钮居中
		  ,shade:  [0.8, '#393D49'] //不显示遮罩
		  ,yes: function(){
		    var data = {};
		  		data.name = $('#name').val();
		  		if(data.name)
		  		{
		  			save(data);
		  		}
		  		else
		  		{
		  			layer.msg('请填写内容');
		  		}
		  }
	});
}


function edit(id,obj)
{
	var name = $(obj).attr('value');
	layer.open({
		  type: 1
		  ,title:'修改渠道'
		  ,offset: 'auto' //具体配置参考：offset参数项
		  ,content: '<div style="padding: 20px 20px;">渠道名称：<input value="'+name+'" type="text" id="name" name="name" class="mr15 w200 text"></div>'
		  ,btn: '修改'
		  ,btnAlign: 'c' //按钮居中
		  ,shade: [0.8, '#393D49'] //不显示遮罩
		  ,yes: function(){
		    var data = {};
		  		data.id = id;
		  		data.name = $('#name').val();
		  		if(data.name)
		  		{
		  			save(data);
		  		}
		  		else
		  		{
		  			layer.msg('请填写内容');
		  		}
		  }
	});
}


function save(data)
{
	layer.load();
		
	data.m = 'saveSource';
	
	var url = '{SITE_URL}ajax/index.php';
	
	var callback = function(data)
	{
		layer.closeAll('loading');
		if(data.sign == 1)
		{
			layer.closeAll();
			
			layer.alert(data.msg,function(){
				window.location = window.location;
			});
		}
		else
		{
			if(data.msg)
			{
				layer.msg(data.msg);
			}
			else
			{
				layer.msg('异常错误');
			}
		}
	};
	makeAjax('post',url,data,callback);
}


</script>
<body>
<div class="wrapper">
	<div class="crumbs"><span style="margin: 0 5px;color: #333;font-size: 14px;">{$fTitle}</span> &gt; <span>{$sTitle}</span> </div>
	
	<div class="container_tit clearfix mb20 ft14">
	
	<form action="{SITE_URL}index.php?a={$action}" method="get">
		<input type="hidden" name="a" value="{$action}" />
        
        <div class="choose fl mr15" style="padding-top: 5px;">
            <span>渠道名称</span>
            <input type="text" id="keyword" name="keyword" class="mr15 w200 text" value="{$parm['keyword']}">
        </div>
       
        <div class="choose fl mr15" style="padding-top: 5px;">
        	<input type="submit" name="submit" class="btnblue mr15" value="搜索">
        </div>
        
        <div class="choose fl mr15" style="padding-top: 5px;">
        	{if adminpermission('X','120000','120001')}
        	<a onclick="add();" href="javascript:;" class="btnyellow mr15">添加渠道</a>
        	{/if}
        </div>
    </form>
    </div>
	
	<!-- list -->
	<table class="table">
		<thead>
			<tr class="bg_h_1">
				<th width="">ID</th>
				<th width="">渠道名称</th>
				<th width="">注册人数</th>
				<th width="">创建人</th>
				<th width="">创建时间</th>
				<th width="">邀请链接</th>
            	<th width="">操作</th>
			</tr>
		</thead>
		<tbody>
		<!--{loop $list $key $one}-->
			<tr>
				<td style="text-align: center;">{$one['id']}</td>
				<td style="text-align: center;">{$one['name']}</td>
				<td style="text-align: center;">{$one['regNums']}</td>
				<td style="text-align: center;">{$one['createUser']}</td>
				<td style="text-align: center;">{php echo time_formart($one['addtime'],2)}</td>
				<td style="text-align: center;"><a id="copy_{$one['id']}" type="copyBtn" class="btn_look" style="cursor:hand" data="{$one['id']}" link="http://www.sohu.com" title="http://www.sohu.com">复制链接</a></td>
				<td style="text-align: center;">
					{if adminpermission('X','120000','120002')}
					<a class="btn_edit" href="javascript:;" onclick="edit('{$one[id]}',this)" value="{$one[name]}"  title="编辑">编辑</a>
					{/if}
					{if adminpermission('X','120000','120005')}
					<a class="btn_look" href="{SITE_URL}index.php?a={$action}&m=caozuo&id={$one[id]}"  title="操作记录">操作记录</a>
					{/if}
				</td>
			</tr>
		<!--{/loop}-->
		</tbody>
	</table>
</div>
<script src="{SITE_URL}static/copy/ZeroClipboard.js?ver=1.0.0"></script>
<script language="JavaScript">
$("[type='copyBtn']").each(function(i){
        var id = $(this).attr('data');
        var clip=null;
        clip = new ZeroClipboard.Client();
        ZeroClipboard.setMoviePath("{SITE_URL}static/copy/ZeroClipboard.swf");  //和html不在同一目录需设置setMoviePath
        clip.setHandCursor( true );
        clip.setText( $("#copy_"+id).attr("link") );
        clip.addEventListener('complete', function (client, text) {
          	layer.msg("复制成功");
        });
        clip.glue('copy_'+id);
  });
</script>

<!--{php pagenav($pageurl,$page,$pagetotal);}-->
{template foot}